package com.edu.exam.entity.exampaper.review;

import com.edu.exam.enums.exampaper.review.ExamPaperCheckTaskStatus;
import com.edu.exam.enums.common.TaskType;
import com.edu.exam.enums.common.Priority;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 批量查重任务实体类
 *
 * <p>管理批量试卷查重任务的生命周期，包括任务创建、执行、监控、
 * 结果汇总等功能。支持多种批量查重策略和任务调度。</p>
 *
 * @author 系统生成
 * @version 2.0
 * @since 2025-11-09
 */
@Entity
@Data
@EqualsAndHashCode(callSuper = false)
@EntityListeners(AuditingEntityListener.class)
public class ExamPaperBatchCheckTask {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 任务名称
     */
    @Column(name = "task_name", nullable = false, length = 200)
    private String taskName;

    /**
     * 任务描述
     */
    @Column(name = "task_description", columnDefinition = "TEXT")
    private String taskDescription;

    /**
     * 任务类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "task_type", nullable = false, length = 20)
    private TaskType taskType;

    /**
     * 任务状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "task_status", nullable = false, length = 20)
    private ExamPaperCheckTaskStatus taskStatus;

    /**
     * 任务优先级
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "priority", nullable = false, length = 20)
    private Priority priority;

    /**
     * 源试卷ID列表
     */
    @Column(name = "source_paper_ids", columnDefinition = "TEXT")
    private String sourcePaperIds;

    /**
     * 目标试卷ID列表
     */
    @Column(name = "target_paper_ids", columnDefinition = "TEXT")
    private String targetPaperIds;

    /**
     * 总试卷数量
     */
    @Column(name = "total_paper_count")
    private Integer totalPaperCount;

    /**
     * 已处理试卷数量
     */
    @Column(name = "processed_paper_count")
    private Integer processedPaperCount;

    /**
     * 成功处理试卷数量
     */
    @Column(name = "success_paper_count")
    private Integer successPaperCount;

    /**
     * 失败处理试卷数量
     */
    @Column(name = "failed_paper_count")
    private Integer failedPaperCount;

    /**
     * 完成进度
     */
    @Column(name = "completion_rate", precision = 5, scale = 2)
    private BigDecimal completionRate;

    /**
     * 相似度阈值
     */
    @Column(name = "similarity_threshold", precision = 5, scale = 2)
    private BigDecimal similarityThreshold;

    /**
     * 查重配置
     */
    @Column(name = "check_config", columnDefinition = "TEXT")
    private String checkConfig;

    /**
     * 批处理大小
     */
    @Column(name = "batch_size")
    private Integer batchSize;

    /**
     * 最大并发数
     */
    @Column(name = "max_concurrency")
    private Integer maxConcurrency;

    /**
     * 任务开始时间
     */
    @Column(name = "start_time")
    private LocalDateTime startTime;

    /**
     * 任务结束时间
     */
    @Column(name = "end_time")
    private LocalDateTime endTime;

    /**
     * 预计完成时间
     */
    @Column(name = "estimated_end_time")
    private LocalDateTime estimatedEndTime;

    /**
     * 执行时长(毫秒)
     */
    @Column(name = "execution_duration")
    private Long executionDuration;

    /**
     * 平均处理时间(毫秒/张)
     */
    @Column(name = "average_processing_time")
    private Long averageProcessingTime;

    /**
     * 计划执行时间
     */
    @Column(name = "scheduled_time")
    private LocalDateTime scheduledTime;

    /**
     * 超时时间(分钟)
     */
    @Column(name = "timeout_minutes")
    private Integer timeoutMinutes;

    /**
     * 重试次数
     */
    @Column(name = "retry_count")
    private Integer retryCount;

    /**
     * 最大重试次数
     */
    @Column(name = "max_retry_count")
    private Integer maxRetryCount;

    /**
     * 任务参数
     */
    @Column(name = "task_params", columnDefinition = "TEXT")
    private String taskParams;

    /**
     * 结果摘要
     */
    @Column(name = "result_summary", columnDefinition = "TEXT")
    private String resultSummary;

    /**
     * 统计信息
     */
    @Column(name = "statistics", columnDefinition = "TEXT")
    private String statistics;

    /**
     * 错误信息
     */
    @Column(name = "error_message", columnDefinition = "TEXT")
    private String errorMessage;

    /**
     * 错误详情
     */
    @Column(name = "error_details", columnDefinition = "TEXT")
    private String errorDetails;

    /**
     * 任务日志
     */
    @Column(name = "task_log", columnDefinition = "TEXT")
    private String taskLog;

    /**
     * 输出文件路径
     */
    @Column(name = "output_file_path", length = 500)
    private String outputFilePath;

    /**
     * 报告文件路径
     */
    @Column(name = "report_file_path", length = 500)
    private String reportFilePath;

    /**
     * 是否发送通知
     */
    @Column(name = "send_notification")
    private Boolean sendNotification;

    /**
     * 通知邮箱列表
     */
    @Column(name = "notification_emails", columnDefinition = "TEXT")
    private String notificationEmails;

    /**
     * 是否自动归档
     */
    @Column(name = "auto_archive")
    private Boolean autoArchive;

    /**
     * 归档时间
     */
    @Column(name = "archive_time")
    private LocalDateTime archiveTime;

    /**
     * 任务执行器信息
     */
    @Column(name = "executor_info", length = 200)
    private String executorInfo;

    /**
     * 算法版本
     */
    @Column(name = "algorithm_version", length = 50)
    private String algorithmVersion;

    /**
     * 系统信息
     */
    @Column(name = "system_info", columnDefinition = "TEXT")
    private String systemInfo;

    /**
     * 扩展属性
     */
    @Column(name = "extended_attributes", columnDefinition = "TEXT")
    private String extendedAttributes;

    /**
     * 备注信息
     */
    @Column(name = "remarks", length = 500)
    private String remarks;

    /**
     * 创建人ID
     */
    @Column(name = "created_by")
    private Long createdBy;

    /**
     * 更新人ID
     */
    @Column(name = "updated_by")
    private Long updatedBy;

    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @LastModifiedDate
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;

    /**
     * 删除时间
     */
    @Column(name = "deleted_time")
    private LocalDateTime deletedTime;

    /**
     * 删除人ID
     */
    @Column(name = "deleted_by")
    private Long deletedBy;

}